﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SWDataDB.DAL;
using SWDataDB.BLL;

public partial class SpatialSearch : System.Web.UI.Page
{
    public string strInput;

    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            GetContent("");
        }

    }
    private void GetContent(string Title)
    {

        strInput = this.Titlename.Text;
        ZLInfo zlobj = new ZLInfo();
        //dl_FileList.DataSource = zlobj.GetAllInfoWithSet();
        //dl_FileList.DataBind();
        DataSet ds = new DataSet();
        if (strInput != null)
        {
            ds = zlobj.GetAllInfobyInput(strInput);
        }
        else if (strInput.Trim() == null)
        {

            ds = zlobj.GetAllInfoWithSet();
        }


        DataTable dt = ds.Tables[0];
        DataView dv = dt.DefaultView;
        //对用于分页的类的引用
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = dt.DefaultView;//设置数据源(DataTable类型)
        pds.AllowPaging = true;


        AspNetPager1.RecordCount = dv.Count;
        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
        pds.PageSize = AspNetPager1.PageSize;
        dl_FileList.DataSource = pds;
        dl_FileList.DataBind();

        //BLL.Content c = new BLL.Content();
        //DataSet ds = c.GetContentDS(Title);
        //dl_FileList.DataSource = ds.Tables[0].DefaultView;
        //dl_FileList.DataBind();
    }


    protected void SearchBtn_Click(object sender, ImageClickEventArgs e)
    {
        string titlename = this.Titlename.Text;
        //ZLInfo zlobj = new ZLInfo();
        //ZLInfoQuery zlinfoquery = new ZLInfoQuery();
        //dl_FileList.DataSource = zlinfoquery.ZLInfoNormalQuery(titlename);

        ////dl_FileList.DataSource = zlobj.GetAllInfobyTitle(titlename);
        //dl_FileList.DataBind();

        GetContent(strInput);
    }


    protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        AspNetPager1.CurrentPageIndex = e.NewPageIndex;
        GetContent("");
    }
}
